// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate lazy_static;
extern crate location;
extern crate longrunning;
extern crate lro;
extern crate reqwest;
extern crate rpc;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// Request message for `CheckOnboardingStatus` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CheckOnboardingStatusRequest {
    /// Required. The resource for which the onboarding status should be checked.
    /// Should be in one of the following formats:
    ///
    /// * `projects/{project-number|project-id}/locations/{region}`
    /// * `folders/{folder-number}/locations/{region}`
    /// * `organizations/{organization-number}/locations/{region}`
    pub parent: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CheckOnboardingStatusRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CheckOnboardingStatusRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }
}

impl wkt::message::Message for CheckOnboardingStatusRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.CheckOnboardingStatusRequest"
    }
}

/// Response message for `CheckOnboardingStatus` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CheckOnboardingStatusResponse {
    /// The service account that PAM uses to act on this resource.
    pub service_account: std::string::String,

    /// List of issues that are preventing PAM from functioning for this resource
    /// and need to be fixed to complete onboarding. Some issues might not be
    /// detected or reported.
    pub findings: std::vec::Vec<crate::model::check_onboarding_status_response::Finding>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CheckOnboardingStatusResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [service_account][crate::model::CheckOnboardingStatusResponse::service_account].
    pub fn set_service_account<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.service_account = v.into();
        self
    }

    /// Sets the value of [findings][crate::model::CheckOnboardingStatusResponse::findings].
    pub fn set_findings<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::check_onboarding_status_response::Finding>,
    {
        use std::iter::Iterator;
        self.findings = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for CheckOnboardingStatusResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.CheckOnboardingStatusResponse"
    }
}

/// Defines additional types related to [CheckOnboardingStatusResponse].
pub mod check_onboarding_status_response {
    #[allow(unused_imports)]
    use super::*;

    /// Finding represents an issue which prevents PAM from functioning properly
    /// for this resource.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Finding {
        pub finding_type: std::option::Option<
            crate::model::check_onboarding_status_response::finding::FindingType,
        >,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Finding {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [finding_type][crate::model::check_onboarding_status_response::Finding::finding_type].
        ///
        /// Note that all the setters affecting `finding_type` are mutually
        /// exclusive.
        pub fn set_finding_type<
            T: std::convert::Into<
                    std::option::Option<
                        crate::model::check_onboarding_status_response::finding::FindingType,
                    >,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.finding_type = v.into();
            self
        }

        /// The value of [finding_type][crate::model::check_onboarding_status_response::Finding::finding_type]
        /// if it holds a `IamAccessDenied`, `None` if the field is not set or
        /// holds a different branch.
        pub fn iam_access_denied(
            &self,
        ) -> std::option::Option<
            &std::boxed::Box<
                crate::model::check_onboarding_status_response::finding::IAMAccessDenied,
            >,
        > {
            #[allow(unreachable_patterns)]
            self.finding_type.as_ref().and_then(|v| match v {
                crate::model::check_onboarding_status_response::finding::FindingType::IamAccessDenied(v) => std::option::Option::Some(v),
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [finding_type][crate::model::check_onboarding_status_response::Finding::finding_type]
        /// to hold a `IamAccessDenied`.
        ///
        /// Note that all the setters affecting `finding_type` are
        /// mutually exclusive.
        pub fn set_iam_access_denied<
            T: std::convert::Into<
                    std::boxed::Box<
                        crate::model::check_onboarding_status_response::finding::IAMAccessDenied,
                    >,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.finding_type = std::option::Option::Some(
                crate::model::check_onboarding_status_response::finding::FindingType::IamAccessDenied(
                    v.into()
                )
            );
            self
        }
    }

    impl wkt::message::Message for Finding {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.CheckOnboardingStatusResponse.Finding"
        }
    }

    /// Defines additional types related to [Finding].
    pub mod finding {
        #[allow(unused_imports)]
        use super::*;

        /// PAM's service account is being denied access by Cloud IAM.
        /// This can be fixed by granting a role that contains the missing
        /// permissions to the service account or exempting it from deny policies if
        /// they are blocking the access.
        #[derive(Clone, Default, PartialEq)]
        #[non_exhaustive]
        pub struct IAMAccessDenied {
            /// List of permissions that are being denied.
            pub missing_permissions: std::vec::Vec<std::string::String>,

            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
        }

        impl IAMAccessDenied {
            pub fn new() -> Self {
                std::default::Default::default()
            }

            /// Sets the value of [missing_permissions][crate::model::check_onboarding_status_response::finding::IAMAccessDenied::missing_permissions].
            pub fn set_missing_permissions<T, V>(mut self, v: T) -> Self
            where
                T: std::iter::IntoIterator<Item = V>,
                V: std::convert::Into<std::string::String>,
            {
                use std::iter::Iterator;
                self.missing_permissions = v.into_iter().map(|i| i.into()).collect();
                self
            }
        }

        impl wkt::message::Message for IAMAccessDenied {
            fn typename() -> &'static str {
                "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.CheckOnboardingStatusResponse.Finding.IAMAccessDenied"
            }
        }

        #[derive(Clone, Debug, PartialEq)]
        #[non_exhaustive]
        pub enum FindingType {
            /// PAM's service account is being denied access by Cloud IAM.
            IamAccessDenied(
                std::boxed::Box<
                    crate::model::check_onboarding_status_response::finding::IAMAccessDenied,
                >,
            ),
        }
    }
}

/// An entitlement defines the eligibility of a set of users to obtain
/// predefined access for some time possibly after going through an approval
/// workflow.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Entitlement {
    /// Identifier. Name of the entitlement.
    /// Possible formats:
    ///
    /// * `organizations/{organization-number}/locations/{region}/entitlements/{entitlement-id}`
    /// * `folders/{folder-number}/locations/{region}/entitlements/{entitlement-id}`
    /// * `projects/{project-id|project-number}/locations/{region}/entitlements/{entitlement-id}`
    pub name: std::string::String,

    /// Output only. Create time stamp.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Update time stamp.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Optional. Who can create grants using this entitlement. This list should
    /// contain at most one entry.
    pub eligible_users: std::vec::Vec<crate::model::AccessControlEntry>,

    /// Optional. The approvals needed before access are granted to a requester. No
    /// approvals are needed if this field is null.
    pub approval_workflow: std::option::Option<crate::model::ApprovalWorkflow>,

    /// The access granted to a requester on successful approval.
    pub privileged_access: std::option::Option<crate::model::PrivilegedAccess>,

    /// Required. The maximum amount of time that access is granted for a request.
    /// A requester can ask for a duration less than this, but never more.
    pub max_request_duration: std::option::Option<wkt::Duration>,

    /// Output only. Current state of this entitlement.
    pub state: crate::model::entitlement::State,

    /// Required. The manner in which the requester should provide a justification
    /// for requesting access.
    pub requester_justification_config:
        std::option::Option<crate::model::entitlement::RequesterJustificationConfig>,

    /// Optional. Additional email addresses to be notified based on actions taken.
    pub additional_notification_targets:
        std::option::Option<crate::model::entitlement::AdditionalNotificationTargets>,

    /// An `etag` is used for optimistic concurrency control as a way to prevent
    /// simultaneous updates to the same entitlement. An `etag` is returned in the
    /// response to `GetEntitlement` and the caller should put the `etag` in the
    /// request to `UpdateEntitlement` so that their change is applied on
    /// the same version. If this field is omitted or if there is a mismatch while
    /// updating an entitlement, then the server rejects the request.
    pub etag: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Entitlement {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Entitlement::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::Entitlement::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::Entitlement::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::Entitlement::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::Entitlement::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [eligible_users][crate::model::Entitlement::eligible_users].
    pub fn set_eligible_users<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::AccessControlEntry>,
    {
        use std::iter::Iterator;
        self.eligible_users = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [approval_workflow][crate::model::Entitlement::approval_workflow].
    pub fn set_approval_workflow<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ApprovalWorkflow>,
    {
        self.approval_workflow = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [approval_workflow][crate::model::Entitlement::approval_workflow].
    pub fn set_or_clear_approval_workflow<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ApprovalWorkflow>,
    {
        self.approval_workflow = v.map(|x| x.into());
        self
    }

    /// Sets the value of [privileged_access][crate::model::Entitlement::privileged_access].
    pub fn set_privileged_access<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::PrivilegedAccess>,
    {
        self.privileged_access = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [privileged_access][crate::model::Entitlement::privileged_access].
    pub fn set_or_clear_privileged_access<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::PrivilegedAccess>,
    {
        self.privileged_access = v.map(|x| x.into());
        self
    }

    /// Sets the value of [max_request_duration][crate::model::Entitlement::max_request_duration].
    pub fn set_max_request_duration<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.max_request_duration = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [max_request_duration][crate::model::Entitlement::max_request_duration].
    pub fn set_or_clear_max_request_duration<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.max_request_duration = v.map(|x| x.into());
        self
    }

    /// Sets the value of [state][crate::model::Entitlement::state].
    pub fn set_state<T: std::convert::Into<crate::model::entitlement::State>>(
        mut self,
        v: T,
    ) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [requester_justification_config][crate::model::Entitlement::requester_justification_config].
    pub fn set_requester_justification_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::entitlement::RequesterJustificationConfig>,
    {
        self.requester_justification_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [requester_justification_config][crate::model::Entitlement::requester_justification_config].
    pub fn set_or_clear_requester_justification_config<T>(
        mut self,
        v: std::option::Option<T>,
    ) -> Self
    where
        T: std::convert::Into<crate::model::entitlement::RequesterJustificationConfig>,
    {
        self.requester_justification_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [additional_notification_targets][crate::model::Entitlement::additional_notification_targets].
    pub fn set_additional_notification_targets<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::entitlement::AdditionalNotificationTargets>,
    {
        self.additional_notification_targets = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [additional_notification_targets][crate::model::Entitlement::additional_notification_targets].
    pub fn set_or_clear_additional_notification_targets<T>(
        mut self,
        v: std::option::Option<T>,
    ) -> Self
    where
        T: std::convert::Into<crate::model::entitlement::AdditionalNotificationTargets>,
    {
        self.additional_notification_targets = v.map(|x| x.into());
        self
    }

    /// Sets the value of [etag][crate::model::Entitlement::etag].
    pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.etag = v.into();
        self
    }
}

impl wkt::message::Message for Entitlement {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Entitlement"
    }
}

/// Defines additional types related to [Entitlement].
pub mod entitlement {
    #[allow(unused_imports)]
    use super::*;

    /// Defines how a requester must provide a justification when requesting
    /// access.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct RequesterJustificationConfig {
        /// This is a required field and the user must explicitly opt out if a
        /// justification from the requester isn't mandatory.
        pub justification_type: std::option::Option<
            crate::model::entitlement::requester_justification_config::JustificationType,
        >,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl RequesterJustificationConfig {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [justification_type][crate::model::entitlement::RequesterJustificationConfig::justification_type].
        ///
        /// Note that all the setters affecting `justification_type` are mutually
        /// exclusive.
        pub fn set_justification_type<T: std::convert::Into<std::option::Option<crate::model::entitlement::requester_justification_config::JustificationType>>>(mut self, v: T) -> Self
        {
            self.justification_type = v.into();
            self
        }

        /// The value of [justification_type][crate::model::entitlement::RequesterJustificationConfig::justification_type]
        /// if it holds a `NotMandatory`, `None` if the field is not set or
        /// holds a different branch.
        pub fn not_mandatory(
            &self,
        ) -> std::option::Option<
            &std::boxed::Box<
                crate::model::entitlement::requester_justification_config::NotMandatory,
            >,
        > {
            #[allow(unreachable_patterns)]
            self.justification_type.as_ref().and_then(|v| match v {
                crate::model::entitlement::requester_justification_config::JustificationType::NotMandatory(v) => std::option::Option::Some(v),
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [justification_type][crate::model::entitlement::RequesterJustificationConfig::justification_type]
        /// to hold a `NotMandatory`.
        ///
        /// Note that all the setters affecting `justification_type` are
        /// mutually exclusive.
        pub fn set_not_mandatory<
            T: std::convert::Into<
                    std::boxed::Box<
                        crate::model::entitlement::requester_justification_config::NotMandatory,
                    >,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.justification_type = std::option::Option::Some(
                crate::model::entitlement::requester_justification_config::JustificationType::NotMandatory(
                    v.into()
                )
            );
            self
        }

        /// The value of [justification_type][crate::model::entitlement::RequesterJustificationConfig::justification_type]
        /// if it holds a `Unstructured`, `None` if the field is not set or
        /// holds a different branch.
        pub fn unstructured(
            &self,
        ) -> std::option::Option<
            &std::boxed::Box<
                crate::model::entitlement::requester_justification_config::Unstructured,
            >,
        > {
            #[allow(unreachable_patterns)]
            self.justification_type.as_ref().and_then(|v| match v {
                crate::model::entitlement::requester_justification_config::JustificationType::Unstructured(v) => std::option::Option::Some(v),
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [justification_type][crate::model::entitlement::RequesterJustificationConfig::justification_type]
        /// to hold a `Unstructured`.
        ///
        /// Note that all the setters affecting `justification_type` are
        /// mutually exclusive.
        pub fn set_unstructured<
            T: std::convert::Into<
                    std::boxed::Box<
                        crate::model::entitlement::requester_justification_config::Unstructured,
                    >,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.justification_type = std::option::Option::Some(
                crate::model::entitlement::requester_justification_config::JustificationType::Unstructured(
                    v.into()
                )
            );
            self
        }
    }

    impl wkt::message::Message for RequesterJustificationConfig {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Entitlement.RequesterJustificationConfig"
        }
    }

    /// Defines additional types related to [RequesterJustificationConfig].
    pub mod requester_justification_config {
        #[allow(unused_imports)]
        use super::*;

        /// The justification is not mandatory but can be provided in any of the
        /// supported formats.
        #[derive(Clone, Default, PartialEq)]
        #[non_exhaustive]
        pub struct NotMandatory {
            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
        }

        impl NotMandatory {
            pub fn new() -> Self {
                std::default::Default::default()
            }
        }

        impl wkt::message::Message for NotMandatory {
            fn typename() -> &'static str {
                "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Entitlement.RequesterJustificationConfig.NotMandatory"
            }
        }

        /// The requester has to provide a justification in the form of a string.
        #[derive(Clone, Default, PartialEq)]
        #[non_exhaustive]
        pub struct Unstructured {
            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
        }

        impl Unstructured {
            pub fn new() -> Self {
                std::default::Default::default()
            }
        }

        impl wkt::message::Message for Unstructured {
            fn typename() -> &'static str {
                "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Entitlement.RequesterJustificationConfig.Unstructured"
            }
        }

        /// This is a required field and the user must explicitly opt out if a
        /// justification from the requester isn't mandatory.
        #[derive(Clone, Debug, PartialEq)]
        #[non_exhaustive]
        pub enum JustificationType {
            /// This option means the requester isn't required to provide a
            /// justification.
            NotMandatory(
                std::boxed::Box<
                    crate::model::entitlement::requester_justification_config::NotMandatory,
                >,
            ),
            /// This option means the requester must provide a string as
            /// justification. If this is selected, the server allows the requester
            /// to provide a justification but doesn't validate it.
            Unstructured(
                std::boxed::Box<
                    crate::model::entitlement::requester_justification_config::Unstructured,
                >,
            ),
        }
    }

    /// `AdditionalNotificationTargets` includes email addresses to be notified.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct AdditionalNotificationTargets {
        /// Optional. Additional email addresses to be notified when a principal
        /// (requester) is granted access.
        pub admin_email_recipients: std::vec::Vec<std::string::String>,

        /// Optional. Additional email address to be notified about an eligible
        /// entitlement.
        pub requester_email_recipients: std::vec::Vec<std::string::String>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl AdditionalNotificationTargets {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [admin_email_recipients][crate::model::entitlement::AdditionalNotificationTargets::admin_email_recipients].
        pub fn set_admin_email_recipients<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.admin_email_recipients = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [requester_email_recipients][crate::model::entitlement::AdditionalNotificationTargets::requester_email_recipients].
        pub fn set_requester_email_recipients<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.requester_email_recipients = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for AdditionalNotificationTargets {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Entitlement.AdditionalNotificationTargets"
        }
    }

    /// Different states an entitlement can be in.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Unspecified state. This value is never returned by the server.
        Unspecified,
        /// The entitlement is being created.
        Creating,
        /// The entitlement is available for requesting access.
        Available,
        /// The entitlement is being deleted.
        Deleting,
        /// The entitlement has been deleted.
        Deleted,
        /// The entitlement is being updated.
        Updating,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Creating => std::option::Option::Some(1),
                Self::Available => std::option::Option::Some(2),
                Self::Deleting => std::option::Option::Some(3),
                Self::Deleted => std::option::Option::Some(4),
                Self::Updating => std::option::Option::Some(5),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Creating => std::option::Option::Some("CREATING"),
                Self::Available => std::option::Option::Some("AVAILABLE"),
                Self::Deleting => std::option::Option::Some("DELETING"),
                Self::Deleted => std::option::Option::Some("DELETED"),
                Self::Updating => std::option::Option::Some("UPDATING"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Creating,
                2 => Self::Available,
                3 => Self::Deleting,
                4 => Self::Deleted,
                5 => Self::Updating,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "CREATING" => Self::Creating,
                "AVAILABLE" => Self::Available,
                "DELETING" => Self::Deleting,
                "DELETED" => Self::Deleted,
                "UPDATING" => Self::Updating,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Creating => serializer.serialize_i32(1),
                Self::Available => serializer.serialize_i32(2),
                Self::Deleting => serializer.serialize_i32(3),
                Self::Deleted => serializer.serialize_i32(4),
                Self::Updating => serializer.serialize_i32(5),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.privilegedaccessmanager.v1.Entitlement.State",
            ))
        }
    }
}

/// `AccessControlEntry` is used to control who can do some operation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AccessControlEntry {
    /// Optional. Users who are allowed for the operation. Each entry should be a
    /// valid v1 IAM principal identifier. The format for these is documented at:
    /// <https://cloud.google.com/iam/docs/principal-identifiers#v1>
    pub principals: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AccessControlEntry {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [principals][crate::model::AccessControlEntry::principals].
    pub fn set_principals<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.principals = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for AccessControlEntry {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.AccessControlEntry"
    }
}

/// Different types of approval workflows that can be used to gate privileged
/// access granting.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ApprovalWorkflow {
    pub approval_workflow: std::option::Option<crate::model::approval_workflow::ApprovalWorkflow>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ApprovalWorkflow {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [approval_workflow][crate::model::ApprovalWorkflow::approval_workflow].
    ///
    /// Note that all the setters affecting `approval_workflow` are mutually
    /// exclusive.
    pub fn set_approval_workflow<
        T: std::convert::Into<std::option::Option<crate::model::approval_workflow::ApprovalWorkflow>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.approval_workflow = v.into();
        self
    }

    /// The value of [approval_workflow][crate::model::ApprovalWorkflow::approval_workflow]
    /// if it holds a `ManualApprovals`, `None` if the field is not set or
    /// holds a different branch.
    pub fn manual_approvals(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::ManualApprovals>> {
        #[allow(unreachable_patterns)]
        self.approval_workflow.as_ref().and_then(|v| match v {
            crate::model::approval_workflow::ApprovalWorkflow::ManualApprovals(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [approval_workflow][crate::model::ApprovalWorkflow::approval_workflow]
    /// to hold a `ManualApprovals`.
    ///
    /// Note that all the setters affecting `approval_workflow` are
    /// mutually exclusive.
    pub fn set_manual_approvals<
        T: std::convert::Into<std::boxed::Box<crate::model::ManualApprovals>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.approval_workflow = std::option::Option::Some(
            crate::model::approval_workflow::ApprovalWorkflow::ManualApprovals(v.into()),
        );
        self
    }
}

impl wkt::message::Message for ApprovalWorkflow {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.ApprovalWorkflow"
    }
}

/// Defines additional types related to [ApprovalWorkflow].
pub mod approval_workflow {
    #[allow(unused_imports)]
    use super::*;

    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum ApprovalWorkflow {
        /// An approval workflow where users designated as approvers review and act
        /// on the grants.
        ManualApprovals(std::boxed::Box<crate::model::ManualApprovals>),
    }
}

/// A manual approval workflow where users who are designated as approvers
/// need to call the `ApproveGrant`/`DenyGrant` APIs for a grant. The workflow
/// can consist of multiple serial steps where each step defines who can act as
/// approver in that step and how many of those users should approve before the
/// workflow moves to the next step.
///
/// This can be used to create approval workflows such as:
///
/// * Require an approval from any user in a group G.
/// * Require an approval from any k number of users from a Group G.
/// * Require an approval from any user in a group G and then from a user U.
///
/// A single user might be part of the `approvers` ACL for multiple steps in this
/// workflow, but they can only approve once and that approval is only considered
/// to satisfy the approval step at which it was granted.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ManualApprovals {
    /// Optional. Do the approvers need to provide a justification for their
    /// actions?
    pub require_approver_justification: bool,

    /// Optional. List of approval steps in this workflow. These steps are followed
    /// in the specified order sequentially. Only 1 step is supported.
    pub steps: std::vec::Vec<crate::model::manual_approvals::Step>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ManualApprovals {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [require_approver_justification][crate::model::ManualApprovals::require_approver_justification].
    pub fn set_require_approver_justification<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.require_approver_justification = v.into();
        self
    }

    /// Sets the value of [steps][crate::model::ManualApprovals::steps].
    pub fn set_steps<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::manual_approvals::Step>,
    {
        use std::iter::Iterator;
        self.steps = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ManualApprovals {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.ManualApprovals"
    }
}

/// Defines additional types related to [ManualApprovals].
pub mod manual_approvals {
    #[allow(unused_imports)]
    use super::*;

    /// Step represents a logical step in a manual approval workflow.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Step {
        /// Optional. The potential set of approvers in this step. This list must
        /// contain at most one entry.
        pub approvers: std::vec::Vec<crate::model::AccessControlEntry>,

        /// Required. How many users from the above list need to approve. If there
        /// aren't enough distinct users in the list, then the workflow indefinitely
        /// blocks. Should always be greater than 0. 1 is the only supported value.
        pub approvals_needed: i32,

        /// Optional. Additional email addresses to be notified when a grant is
        /// pending approval.
        pub approver_email_recipients: std::vec::Vec<std::string::String>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Step {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [approvers][crate::model::manual_approvals::Step::approvers].
        pub fn set_approvers<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::AccessControlEntry>,
        {
            use std::iter::Iterator;
            self.approvers = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [approvals_needed][crate::model::manual_approvals::Step::approvals_needed].
        pub fn set_approvals_needed<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
            self.approvals_needed = v.into();
            self
        }

        /// Sets the value of [approver_email_recipients][crate::model::manual_approvals::Step::approver_email_recipients].
        pub fn set_approver_email_recipients<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.approver_email_recipients = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for Step {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.ManualApprovals.Step"
        }
    }
}

/// Privileged access that this service can be used to gate.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PrivilegedAccess {
    pub access_type: std::option::Option<crate::model::privileged_access::AccessType>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PrivilegedAccess {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [access_type][crate::model::PrivilegedAccess::access_type].
    ///
    /// Note that all the setters affecting `access_type` are mutually
    /// exclusive.
    pub fn set_access_type<
        T: std::convert::Into<std::option::Option<crate::model::privileged_access::AccessType>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.access_type = v.into();
        self
    }

    /// The value of [access_type][crate::model::PrivilegedAccess::access_type]
    /// if it holds a `GcpIamAccess`, `None` if the field is not set or
    /// holds a different branch.
    pub fn gcp_iam_access(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::privileged_access::GcpIamAccess>> {
        #[allow(unreachable_patterns)]
        self.access_type.as_ref().and_then(|v| match v {
            crate::model::privileged_access::AccessType::GcpIamAccess(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [access_type][crate::model::PrivilegedAccess::access_type]
    /// to hold a `GcpIamAccess`.
    ///
    /// Note that all the setters affecting `access_type` are
    /// mutually exclusive.
    pub fn set_gcp_iam_access<
        T: std::convert::Into<std::boxed::Box<crate::model::privileged_access::GcpIamAccess>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.access_type = std::option::Option::Some(
            crate::model::privileged_access::AccessType::GcpIamAccess(v.into()),
        );
        self
    }
}

impl wkt::message::Message for PrivilegedAccess {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.PrivilegedAccess"
    }
}

/// Defines additional types related to [PrivilegedAccess].
pub mod privileged_access {
    #[allow(unused_imports)]
    use super::*;

    /// `GcpIamAccess` represents IAM based access control on a Google Cloud
    /// resource. Refer to <https://cloud.google.com/iam/docs> to understand more
    /// about IAM.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct GcpIamAccess {
        /// Required. The type of this resource.
        pub resource_type: std::string::String,

        /// Required. Name of the resource.
        pub resource: std::string::String,

        /// Required. Role bindings that are created on successful grant.
        pub role_bindings:
            std::vec::Vec<crate::model::privileged_access::gcp_iam_access::RoleBinding>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl GcpIamAccess {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [resource_type][crate::model::privileged_access::GcpIamAccess::resource_type].
        pub fn set_resource_type<T: std::convert::Into<std::string::String>>(
            mut self,
            v: T,
        ) -> Self {
            self.resource_type = v.into();
            self
        }

        /// Sets the value of [resource][crate::model::privileged_access::GcpIamAccess::resource].
        pub fn set_resource<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.resource = v.into();
            self
        }

        /// Sets the value of [role_bindings][crate::model::privileged_access::GcpIamAccess::role_bindings].
        pub fn set_role_bindings<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::privileged_access::gcp_iam_access::RoleBinding>,
        {
            use std::iter::Iterator;
            self.role_bindings = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for GcpIamAccess {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.PrivilegedAccess.GcpIamAccess"
        }
    }

    /// Defines additional types related to [GcpIamAccess].
    pub mod gcp_iam_access {
        #[allow(unused_imports)]
        use super::*;

        /// IAM role bindings that are created after a successful grant.
        #[derive(Clone, Default, PartialEq)]
        #[non_exhaustive]
        pub struct RoleBinding {
            /// Required. IAM role to be granted.
            /// <https://cloud.google.com/iam/docs/roles-overview>.
            pub role: std::string::String,

            /// Optional. The expression field of the IAM condition to be associated
            /// with the role. If specified, a user with an active grant for this
            /// entitlement is able to access the resource only if this condition
            /// evaluates to true for their request.
            ///
            /// This field uses the same CEL format as IAM and supports all attributes
            /// that IAM supports, except tags.
            /// <https://cloud.google.com/iam/docs/conditions-overview#attributes>.
            pub condition_expression: std::string::String,

            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
        }

        impl RoleBinding {
            pub fn new() -> Self {
                std::default::Default::default()
            }

            /// Sets the value of [role][crate::model::privileged_access::gcp_iam_access::RoleBinding::role].
            pub fn set_role<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
                self.role = v.into();
                self
            }

            /// Sets the value of [condition_expression][crate::model::privileged_access::gcp_iam_access::RoleBinding::condition_expression].
            pub fn set_condition_expression<T: std::convert::Into<std::string::String>>(
                mut self,
                v: T,
            ) -> Self {
                self.condition_expression = v.into();
                self
            }
        }

        impl wkt::message::Message for RoleBinding {
            fn typename() -> &'static str {
                "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.PrivilegedAccess.GcpIamAccess.RoleBinding"
            }
        }
    }

    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum AccessType {
        /// Access to a Google Cloud resource through IAM.
        GcpIamAccess(std::boxed::Box<crate::model::privileged_access::GcpIamAccess>),
    }
}

/// Message for requesting list of entitlements.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListEntitlementsRequest {
    /// Required. The parent which owns the entitlement resources.
    pub parent: std::string::String,

    /// Optional. Requested page size. Server may return fewer items than
    /// requested. If unspecified, the server picks an appropriate default.
    pub page_size: i32,

    /// Optional. A token identifying a page of results the server should return.
    pub page_token: std::string::String,

    /// Optional. Filtering results.
    pub filter: std::string::String,

    /// Optional. Hint for how to order the results.
    pub order_by: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListEntitlementsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListEntitlementsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListEntitlementsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListEntitlementsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListEntitlementsRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [order_by][crate::model::ListEntitlementsRequest::order_by].
    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.order_by = v.into();
        self
    }
}

impl wkt::message::Message for ListEntitlementsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.ListEntitlementsRequest"
    }
}

/// Message for response to listing entitlements.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListEntitlementsResponse {
    /// The list of entitlements.
    pub entitlements: std::vec::Vec<crate::model::Entitlement>,

    /// A token identifying a page of results the server should return.
    pub next_page_token: std::string::String,

    /// Locations that could not be reached.
    pub unreachable: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListEntitlementsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [entitlements][crate::model::ListEntitlementsResponse::entitlements].
    pub fn set_entitlements<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Entitlement>,
    {
        use std::iter::Iterator;
        self.entitlements = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListEntitlementsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable][crate::model::ListEntitlementsResponse::unreachable].
    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListEntitlementsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.ListEntitlementsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListEntitlementsResponse {
    type PageItem = crate::model::Entitlement;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.entitlements
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Request message for `SearchEntitlements` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SearchEntitlementsRequest {
    /// Required. The parent which owns the entitlement resources.
    pub parent: std::string::String,

    /// Required. Only entitlements where the calling user has this access are
    /// returned.
    pub caller_access_type: crate::model::search_entitlements_request::CallerAccessType,

    /// Optional. Only entitlements matching this filter are returned in the
    /// response.
    pub filter: std::string::String,

    /// Optional. Requested page size. The server may return fewer items than
    /// requested. If unspecified, the server picks an appropriate default.
    pub page_size: i32,

    /// Optional. A token identifying a page of results the server should return.
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SearchEntitlementsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::SearchEntitlementsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [caller_access_type][crate::model::SearchEntitlementsRequest::caller_access_type].
    pub fn set_caller_access_type<
        T: std::convert::Into<crate::model::search_entitlements_request::CallerAccessType>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.caller_access_type = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::SearchEntitlementsRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::SearchEntitlementsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::SearchEntitlementsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for SearchEntitlementsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.SearchEntitlementsRequest"
    }
}

/// Defines additional types related to [SearchEntitlementsRequest].
pub mod search_entitlements_request {
    #[allow(unused_imports)]
    use super::*;

    /// Different types of access a user can have on the entitlement resource.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum CallerAccessType {
        /// Unspecified access type.
        Unspecified,
        /// The user has access to create grants using this entitlement.
        GrantRequester,
        /// The user has access to approve/deny grants created under this
        /// entitlement.
        GrantApprover,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [CallerAccessType::value] or
        /// [CallerAccessType::name].
        UnknownValue(caller_access_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod caller_access_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl CallerAccessType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::GrantRequester => std::option::Option::Some(1),
                Self::GrantApprover => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("CALLER_ACCESS_TYPE_UNSPECIFIED"),
                Self::GrantRequester => std::option::Option::Some("GRANT_REQUESTER"),
                Self::GrantApprover => std::option::Option::Some("GRANT_APPROVER"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for CallerAccessType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for CallerAccessType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for CallerAccessType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::GrantRequester,
                2 => Self::GrantApprover,
                _ => Self::UnknownValue(caller_access_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for CallerAccessType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "CALLER_ACCESS_TYPE_UNSPECIFIED" => Self::Unspecified,
                "GRANT_REQUESTER" => Self::GrantRequester,
                "GRANT_APPROVER" => Self::GrantApprover,
                _ => Self::UnknownValue(caller_access_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for CallerAccessType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::GrantRequester => serializer.serialize_i32(1),
                Self::GrantApprover => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for CallerAccessType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<CallerAccessType>::new(
                ".google.cloud.privilegedaccessmanager.v1.SearchEntitlementsRequest.CallerAccessType"))
        }
    }
}

/// Response message for `SearchEntitlements` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SearchEntitlementsResponse {
    /// The list of entitlements.
    pub entitlements: std::vec::Vec<crate::model::Entitlement>,

    /// A token identifying a page of results the server should return.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SearchEntitlementsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [entitlements][crate::model::SearchEntitlementsResponse::entitlements].
    pub fn set_entitlements<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Entitlement>,
    {
        use std::iter::Iterator;
        self.entitlements = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::SearchEntitlementsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for SearchEntitlementsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.SearchEntitlementsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for SearchEntitlementsResponse {
    type PageItem = crate::model::Entitlement;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.entitlements
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Message for getting an entitlement.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetEntitlementRequest {
    /// Required. Name of the resource.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetEntitlementRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetEntitlementRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetEntitlementRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.GetEntitlementRequest"
    }
}

/// Message for creating an entitlement.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateEntitlementRequest {
    /// Required. Name of the parent resource for the entitlement.
    /// Possible formats:
    ///
    /// * `organizations/{organization-number}/locations/{region}`
    /// * `folders/{folder-number}/locations/{region}`
    /// * `projects/{project-id|project-number}/locations/{region}`
    pub parent: std::string::String,

    /// Required. The ID to use for this entitlement. This becomes the last part of
    /// the resource name.
    ///
    /// This value should be 4-63 characters in length, and valid characters are
    /// "[a-z]", "[0-9]", and "-". The first character should be from [a-z].
    ///
    /// This value should be unique among all other entitlements under the
    /// specified `parent`.
    pub entitlement_id: std::string::String,

    /// Required. The resource being created
    pub entitlement: std::option::Option<crate::model::Entitlement>,

    /// Optional. An optional request ID to identify requests. Specify a unique
    /// request ID so that if you must retry your request, the server knows to
    /// ignore the request if it has already been completed. The server guarantees
    /// this for at least 60 minutes after the first request.
    ///
    /// For example, consider a situation where you make an initial request and the
    /// request times out. If you make the request again with the same request
    /// ID, the server can check if original operation with the same request ID
    /// was received, and if so, ignores the second request and returns the
    /// previous operation's response. This prevents clients from accidentally
    /// creating duplicate entitlements.
    ///
    /// The request ID must be a valid UUID with the exception that zero UUID is
    /// not supported (00000000-0000-0000-0000-000000000000).
    pub request_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateEntitlementRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateEntitlementRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [entitlement_id][crate::model::CreateEntitlementRequest::entitlement_id].
    pub fn set_entitlement_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.entitlement_id = v.into();
        self
    }

    /// Sets the value of [entitlement][crate::model::CreateEntitlementRequest::entitlement].
    pub fn set_entitlement<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Entitlement>,
    {
        self.entitlement = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [entitlement][crate::model::CreateEntitlementRequest::entitlement].
    pub fn set_or_clear_entitlement<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Entitlement>,
    {
        self.entitlement = v.map(|x| x.into());
        self
    }

    /// Sets the value of [request_id][crate::model::CreateEntitlementRequest::request_id].
    pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_id = v.into();
        self
    }
}

impl wkt::message::Message for CreateEntitlementRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.CreateEntitlementRequest"
    }
}

/// Message for deleting an entitlement.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteEntitlementRequest {
    /// Required. Name of the resource.
    pub name: std::string::String,

    /// Optional. An optional request ID to identify requests. Specify a unique
    /// request ID so that if you must retry your request, the server knows to
    /// ignore the request if it has already been completed. The server guarantees
    /// this for at least 60 minutes after the first request.
    ///
    /// For example, consider a situation where you make an initial request and the
    /// request times out. If you make the request again with the same request
    /// ID, the server can check if original operation with the same request ID
    /// was received, and if so, ignores the second request.
    ///
    /// The request ID must be a valid UUID with the exception that zero UUID is
    /// not supported (00000000-0000-0000-0000-000000000000).
    pub request_id: std::string::String,

    /// Optional. If set to true, any child grant under this entitlement is also
    /// deleted. (Otherwise, the request only works if the entitlement has no child
    /// grant.)
    pub force: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteEntitlementRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteEntitlementRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [request_id][crate::model::DeleteEntitlementRequest::request_id].
    pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_id = v.into();
        self
    }

    /// Sets the value of [force][crate::model::DeleteEntitlementRequest::force].
    pub fn set_force<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.force = v.into();
        self
    }
}

impl wkt::message::Message for DeleteEntitlementRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.DeleteEntitlementRequest"
    }
}

/// Message for updating an entitlement.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateEntitlementRequest {
    /// Required. The entitlement resource that is updated.
    pub entitlement: std::option::Option<crate::model::Entitlement>,

    /// Required. The list of fields to update. A field is overwritten if, and only
    /// if, it is in the mask. Any immutable fields set in the mask are ignored by
    /// the server. Repeated fields and map fields are only allowed in the last
    /// position of a `paths` string and overwrite the existing values. Hence an
    /// update to a repeated field or a map should contain the entire list of
    /// values. The fields specified in the update_mask are relative to the
    /// resource and not to the request.
    /// (e.g. `MaxRequestDuration`; *not* `entitlement.MaxRequestDuration`)
    /// A value of '*' for this field refers to full replacement of the resource.
    pub update_mask: std::option::Option<wkt::FieldMask>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateEntitlementRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [entitlement][crate::model::UpdateEntitlementRequest::entitlement].
    pub fn set_entitlement<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Entitlement>,
    {
        self.entitlement = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [entitlement][crate::model::UpdateEntitlementRequest::entitlement].
    pub fn set_or_clear_entitlement<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Entitlement>,
    {
        self.entitlement = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_mask][crate::model::UpdateEntitlementRequest::update_mask].
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdateEntitlementRequest::update_mask].
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UpdateEntitlementRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.UpdateEntitlementRequest"
    }
}

/// A grant represents a request from a user for obtaining the access specified
/// in an entitlement they are eligible for.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Grant {
    /// Identifier. Name of this grant.
    /// Possible formats:
    ///
    /// * `organizations/{organization-number}/locations/{region}/entitlements/{entitlement-id}/grants/{grant-id}`
    /// * `folders/{folder-number}/locations/{region}/entitlements/{entitlement-id}/grants/{grant-id}`
    /// * `projects/{project-id|project-number}/locations/{region}/entitlements/{entitlement-id}/grants/{grant-id}`
    ///
    /// The last segment of this name (`{grant-id}`) is autogenerated.
    pub name: std::string::String,

    /// Output only. Create time stamp.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Update time stamp.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Username of the user who created this grant.
    pub requester: std::string::String,

    /// Required. The amount of time access is needed for. This value should be
    /// less than the `max_request_duration` value of the entitlement.
    pub requested_duration: std::option::Option<wkt::Duration>,

    /// Optional. Justification of why this access is needed.
    pub justification: std::option::Option<crate::model::Justification>,

    /// Output only. Current state of this grant.
    pub state: crate::model::grant::State,

    /// Output only. Timeline of this grant.
    pub timeline: std::option::Option<crate::model::grant::Timeline>,

    /// Output only. The access that would be granted by this grant.
    pub privileged_access: std::option::Option<crate::model::PrivilegedAccess>,

    /// Output only. Audit trail of access provided by this grant. If unspecified
    /// then access was never granted.
    pub audit_trail: std::option::Option<crate::model::grant::AuditTrail>,

    /// Optional. Additional email addresses to notify for all the actions
    /// performed on the grant.
    pub additional_email_recipients: std::vec::Vec<std::string::String>,

    /// Output only. Flag set by the PAM system to indicate that policy bindings
    /// made by this grant have been modified from outside PAM.
    ///
    /// After it is set, this flag remains set forever irrespective of the grant
    /// state. A `true` value here indicates that PAM no longer has any certainty
    /// on the access a user has because of this grant.
    pub externally_modified: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Grant {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Grant::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::Grant::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::Grant::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::Grant::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::Grant::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [requester][crate::model::Grant::requester].
    pub fn set_requester<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.requester = v.into();
        self
    }

    /// Sets the value of [requested_duration][crate::model::Grant::requested_duration].
    pub fn set_requested_duration<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.requested_duration = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [requested_duration][crate::model::Grant::requested_duration].
    pub fn set_or_clear_requested_duration<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Duration>,
    {
        self.requested_duration = v.map(|x| x.into());
        self
    }

    /// Sets the value of [justification][crate::model::Grant::justification].
    pub fn set_justification<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Justification>,
    {
        self.justification = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [justification][crate::model::Grant::justification].
    pub fn set_or_clear_justification<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Justification>,
    {
        self.justification = v.map(|x| x.into());
        self
    }

    /// Sets the value of [state][crate::model::Grant::state].
    pub fn set_state<T: std::convert::Into<crate::model::grant::State>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [timeline][crate::model::Grant::timeline].
    pub fn set_timeline<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::grant::Timeline>,
    {
        self.timeline = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [timeline][crate::model::Grant::timeline].
    pub fn set_or_clear_timeline<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::grant::Timeline>,
    {
        self.timeline = v.map(|x| x.into());
        self
    }

    /// Sets the value of [privileged_access][crate::model::Grant::privileged_access].
    pub fn set_privileged_access<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::PrivilegedAccess>,
    {
        self.privileged_access = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [privileged_access][crate::model::Grant::privileged_access].
    pub fn set_or_clear_privileged_access<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::PrivilegedAccess>,
    {
        self.privileged_access = v.map(|x| x.into());
        self
    }

    /// Sets the value of [audit_trail][crate::model::Grant::audit_trail].
    pub fn set_audit_trail<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::grant::AuditTrail>,
    {
        self.audit_trail = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [audit_trail][crate::model::Grant::audit_trail].
    pub fn set_or_clear_audit_trail<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::grant::AuditTrail>,
    {
        self.audit_trail = v.map(|x| x.into());
        self
    }

    /// Sets the value of [additional_email_recipients][crate::model::Grant::additional_email_recipients].
    pub fn set_additional_email_recipients<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.additional_email_recipients = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [externally_modified][crate::model::Grant::externally_modified].
    pub fn set_externally_modified<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.externally_modified = v.into();
        self
    }
}

impl wkt::message::Message for Grant {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant"
    }
}

/// Defines additional types related to [Grant].
pub mod grant {
    #[allow(unused_imports)]
    use super::*;

    /// Timeline of a grant describing what happened to it and when.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Timeline {
        /// Output only. The events that have occurred on this grant. This list
        /// contains entries in the same order as they occurred. The first entry is
        /// always be of type `Requested` and there is always at least one entry in
        /// this array.
        pub events: std::vec::Vec<crate::model::grant::timeline::Event>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Timeline {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [events][crate::model::grant::Timeline::events].
        pub fn set_events<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::grant::timeline::Event>,
        {
            use std::iter::Iterator;
            self.events = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for Timeline {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.Timeline"
        }
    }

    /// Defines additional types related to [Timeline].
    pub mod timeline {
        #[allow(unused_imports)]
        use super::*;

        /// A single operation on the grant.
        #[derive(Clone, Default, PartialEq)]
        #[non_exhaustive]
        pub struct Event {
            /// Output only. The time (as recorded at server) when this event occurred.
            pub event_time: std::option::Option<wkt::Timestamp>,

            pub event: std::option::Option<crate::model::grant::timeline::event::Event>,

            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
        }

        impl Event {
            pub fn new() -> Self {
                std::default::Default::default()
            }

            /// Sets the value of [event_time][crate::model::grant::timeline::Event::event_time].
            pub fn set_event_time<T>(mut self, v: T) -> Self
            where
                T: std::convert::Into<wkt::Timestamp>,
            {
                self.event_time = std::option::Option::Some(v.into());
                self
            }

            /// Sets or clears the value of [event_time][crate::model::grant::timeline::Event::event_time].
            pub fn set_or_clear_event_time<T>(mut self, v: std::option::Option<T>) -> Self
            where
                T: std::convert::Into<wkt::Timestamp>,
            {
                self.event_time = v.map(|x| x.into());
                self
            }

            /// Sets the value of [event][crate::model::grant::timeline::Event::event].
            ///
            /// Note that all the setters affecting `event` are mutually
            /// exclusive.
            pub fn set_event<
                T: std::convert::Into<
                        std::option::Option<crate::model::grant::timeline::event::Event>,
                    >,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.event = v.into();
                self
            }

            /// The value of [event][crate::model::grant::timeline::Event::event]
            /// if it holds a `Requested`, `None` if the field is not set or
            /// holds a different branch.
            pub fn requested(
                &self,
            ) -> std::option::Option<
                &std::boxed::Box<crate::model::grant::timeline::event::Requested>,
            > {
                #[allow(unreachable_patterns)]
                self.event.as_ref().and_then(|v| match v {
                    crate::model::grant::timeline::event::Event::Requested(v) => {
                        std::option::Option::Some(v)
                    }
                    _ => std::option::Option::None,
                })
            }

            /// Sets the value of [event][crate::model::grant::timeline::Event::event]
            /// to hold a `Requested`.
            ///
            /// Note that all the setters affecting `event` are
            /// mutually exclusive.
            pub fn set_requested<
                T: std::convert::Into<
                        std::boxed::Box<crate::model::grant::timeline::event::Requested>,
                    >,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.event = std::option::Option::Some(
                    crate::model::grant::timeline::event::Event::Requested(v.into()),
                );
                self
            }

            /// The value of [event][crate::model::grant::timeline::Event::event]
            /// if it holds a `Approved`, `None` if the field is not set or
            /// holds a different branch.
            pub fn approved(
                &self,
            ) -> std::option::Option<&std::boxed::Box<crate::model::grant::timeline::event::Approved>>
            {
                #[allow(unreachable_patterns)]
                self.event.as_ref().and_then(|v| match v {
                    crate::model::grant::timeline::event::Event::Approved(v) => {
                        std::option::Option::Some(v)
                    }
                    _ => std::option::Option::None,
                })
            }

            /// Sets the value of [event][crate::model::grant::timeline::Event::event]
            /// to hold a `Approved`.
            ///
            /// Note that all the setters affecting `event` are
            /// mutually exclusive.
            pub fn set_approved<
                T: std::convert::Into<std::boxed::Box<crate::model::grant::timeline::event::Approved>>,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.event = std::option::Option::Some(
                    crate::model::grant::timeline::event::Event::Approved(v.into()),
                );
                self
            }

            /// The value of [event][crate::model::grant::timeline::Event::event]
            /// if it holds a `Denied`, `None` if the field is not set or
            /// holds a different branch.
            pub fn denied(
                &self,
            ) -> std::option::Option<&std::boxed::Box<crate::model::grant::timeline::event::Denied>>
            {
                #[allow(unreachable_patterns)]
                self.event.as_ref().and_then(|v| match v {
                    crate::model::grant::timeline::event::Event::Denied(v) => {
                        std::option::Option::Some(v)
                    }
                    _ => std::option::Option::None,
                })
            }

            /// Sets the value of [event][crate::model::grant::timeline::Event::event]
            /// to hold a `Denied`.
            ///
            /// Note that all the setters affecting `event` are
            /// mutually exclusive.
            pub fn set_denied<
                T: std::convert::Into<std::boxed::Box<crate::model::grant::timeline::event::Denied>>,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.event = std::option::Option::Some(
                    crate::model::grant::timeline::event::Event::Denied(v.into()),
                );
                self
            }

            /// The value of [event][crate::model::grant::timeline::Event::event]
            /// if it holds a `Revoked`, `None` if the field is not set or
            /// holds a different branch.
            pub fn revoked(
                &self,
            ) -> std::option::Option<&std::boxed::Box<crate::model::grant::timeline::event::Revoked>>
            {
                #[allow(unreachable_patterns)]
                self.event.as_ref().and_then(|v| match v {
                    crate::model::grant::timeline::event::Event::Revoked(v) => {
                        std::option::Option::Some(v)
                    }
                    _ => std::option::Option::None,
                })
            }

            /// Sets the value of [event][crate::model::grant::timeline::Event::event]
            /// to hold a `Revoked`.
            ///
            /// Note that all the setters affecting `event` are
            /// mutually exclusive.
            pub fn set_revoked<
                T: std::convert::Into<std::boxed::Box<crate::model::grant::timeline::event::Revoked>>,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.event = std::option::Option::Some(
                    crate::model::grant::timeline::event::Event::Revoked(v.into()),
                );
                self
            }

            /// The value of [event][crate::model::grant::timeline::Event::event]
            /// if it holds a `Scheduled`, `None` if the field is not set or
            /// holds a different branch.
            pub fn scheduled(
                &self,
            ) -> std::option::Option<
                &std::boxed::Box<crate::model::grant::timeline::event::Scheduled>,
            > {
                #[allow(unreachable_patterns)]
                self.event.as_ref().and_then(|v| match v {
                    crate::model::grant::timeline::event::Event::Scheduled(v) => {
                        std::option::Option::Some(v)
                    }
                    _ => std::option::Option::None,
                })
            }

            /// Sets the value of [event][crate::model::grant::timeline::Event::event]
            /// to hold a `Scheduled`.
            ///
            /// Note that all the setters affecting `event` are
            /// mutually exclusive.
            pub fn set_scheduled<
                T: std::convert::Into<
                        std::boxed::Box<crate::model::grant::timeline::event::Scheduled>,
                    >,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.event = std::option::Option::Some(
                    crate::model::grant::timeline::event::Event::Scheduled(v.into()),
                );
                self
            }

            /// The value of [event][crate::model::grant::timeline::Event::event]
            /// if it holds a `Activated`, `None` if the field is not set or
            /// holds a different branch.
            pub fn activated(
                &self,
            ) -> std::option::Option<
                &std::boxed::Box<crate::model::grant::timeline::event::Activated>,
            > {
                #[allow(unreachable_patterns)]
                self.event.as_ref().and_then(|v| match v {
                    crate::model::grant::timeline::event::Event::Activated(v) => {
                        std::option::Option::Some(v)
                    }
                    _ => std::option::Option::None,
                })
            }

            /// Sets the value of [event][crate::model::grant::timeline::Event::event]
            /// to hold a `Activated`.
            ///
            /// Note that all the setters affecting `event` are
            /// mutually exclusive.
            pub fn set_activated<
                T: std::convert::Into<
                        std::boxed::Box<crate::model::grant::timeline::event::Activated>,
                    >,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.event = std::option::Option::Some(
                    crate::model::grant::timeline::event::Event::Activated(v.into()),
                );
                self
            }

            /// The value of [event][crate::model::grant::timeline::Event::event]
            /// if it holds a `ActivationFailed`, `None` if the field is not set or
            /// holds a different branch.
            pub fn activation_failed(
                &self,
            ) -> std::option::Option<
                &std::boxed::Box<crate::model::grant::timeline::event::ActivationFailed>,
            > {
                #[allow(unreachable_patterns)]
                self.event.as_ref().and_then(|v| match v {
                    crate::model::grant::timeline::event::Event::ActivationFailed(v) => {
                        std::option::Option::Some(v)
                    }
                    _ => std::option::Option::None,
                })
            }

            /// Sets the value of [event][crate::model::grant::timeline::Event::event]
            /// to hold a `ActivationFailed`.
            ///
            /// Note that all the setters affecting `event` are
            /// mutually exclusive.
            pub fn set_activation_failed<
                T: std::convert::Into<
                        std::boxed::Box<crate::model::grant::timeline::event::ActivationFailed>,
                    >,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.event = std::option::Option::Some(
                    crate::model::grant::timeline::event::Event::ActivationFailed(v.into()),
                );
                self
            }

            /// The value of [event][crate::model::grant::timeline::Event::event]
            /// if it holds a `Expired`, `None` if the field is not set or
            /// holds a different branch.
            pub fn expired(
                &self,
            ) -> std::option::Option<&std::boxed::Box<crate::model::grant::timeline::event::Expired>>
            {
                #[allow(unreachable_patterns)]
                self.event.as_ref().and_then(|v| match v {
                    crate::model::grant::timeline::event::Event::Expired(v) => {
                        std::option::Option::Some(v)
                    }
                    _ => std::option::Option::None,
                })
            }

            /// Sets the value of [event][crate::model::grant::timeline::Event::event]
            /// to hold a `Expired`.
            ///
            /// Note that all the setters affecting `event` are
            /// mutually exclusive.
            pub fn set_expired<
                T: std::convert::Into<std::boxed::Box<crate::model::grant::timeline::event::Expired>>,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.event = std::option::Option::Some(
                    crate::model::grant::timeline::event::Event::Expired(v.into()),
                );
                self
            }

            /// The value of [event][crate::model::grant::timeline::Event::event]
            /// if it holds a `Ended`, `None` if the field is not set or
            /// holds a different branch.
            pub fn ended(
                &self,
            ) -> std::option::Option<&std::boxed::Box<crate::model::grant::timeline::event::Ended>>
            {
                #[allow(unreachable_patterns)]
                self.event.as_ref().and_then(|v| match v {
                    crate::model::grant::timeline::event::Event::Ended(v) => {
                        std::option::Option::Some(v)
                    }
                    _ => std::option::Option::None,
                })
            }

            /// Sets the value of [event][crate::model::grant::timeline::Event::event]
            /// to hold a `Ended`.
            ///
            /// Note that all the setters affecting `event` are
            /// mutually exclusive.
            pub fn set_ended<
                T: std::convert::Into<std::boxed::Box<crate::model::grant::timeline::event::Ended>>,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.event = std::option::Option::Some(
                    crate::model::grant::timeline::event::Event::Ended(v.into()),
                );
                self
            }

            /// The value of [event][crate::model::grant::timeline::Event::event]
            /// if it holds a `ExternallyModified`, `None` if the field is not set or
            /// holds a different branch.
            pub fn externally_modified(
                &self,
            ) -> std::option::Option<
                &std::boxed::Box<crate::model::grant::timeline::event::ExternallyModified>,
            > {
                #[allow(unreachable_patterns)]
                self.event.as_ref().and_then(|v| match v {
                    crate::model::grant::timeline::event::Event::ExternallyModified(v) => {
                        std::option::Option::Some(v)
                    }
                    _ => std::option::Option::None,
                })
            }

            /// Sets the value of [event][crate::model::grant::timeline::Event::event]
            /// to hold a `ExternallyModified`.
            ///
            /// Note that all the setters affecting `event` are
            /// mutually exclusive.
            pub fn set_externally_modified<
                T: std::convert::Into<
                        std::boxed::Box<crate::model::grant::timeline::event::ExternallyModified>,
                    >,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.event = std::option::Option::Some(
                    crate::model::grant::timeline::event::Event::ExternallyModified(v.into()),
                );
                self
            }

            /// The value of [event][crate::model::grant::timeline::Event::event]
            /// if it holds a `Withdrawn`, `None` if the field is not set or
            /// holds a different branch.
            pub fn withdrawn(
                &self,
            ) -> std::option::Option<
                &std::boxed::Box<crate::model::grant::timeline::event::Withdrawn>,
            > {
                #[allow(unreachable_patterns)]
                self.event.as_ref().and_then(|v| match v {
                    crate::model::grant::timeline::event::Event::Withdrawn(v) => {
                        std::option::Option::Some(v)
                    }
                    _ => std::option::Option::None,
                })
            }

            /// Sets the value of [event][crate::model::grant::timeline::Event::event]
            /// to hold a `Withdrawn`.
            ///
            /// Note that all the setters affecting `event` are
            /// mutually exclusive.
            pub fn set_withdrawn<
                T: std::convert::Into<
                        std::boxed::Box<crate::model::grant::timeline::event::Withdrawn>,
                    >,
            >(
                mut self,
                v: T,
            ) -> Self {
                self.event = std::option::Option::Some(
                    crate::model::grant::timeline::event::Event::Withdrawn(v.into()),
                );
                self
            }
        }

        impl wkt::message::Message for Event {
            fn typename() -> &'static str {
                "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.Timeline.Event"
            }
        }

        /// Defines additional types related to [Event].
        pub mod event {
            #[allow(unused_imports)]
            use super::*;

            /// An event representing that a grant was requested.
            #[derive(Clone, Default, PartialEq)]
            #[non_exhaustive]
            pub struct Requested {
                /// Output only. The time at which this grant expires unless the approval
                /// workflow completes. If omitted, then the request never expires.
                pub expire_time: std::option::Option<wkt::Timestamp>,

                pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
            }

            impl Requested {
                pub fn new() -> Self {
                    std::default::Default::default()
                }

                /// Sets the value of [expire_time][crate::model::grant::timeline::event::Requested::expire_time].
                pub fn set_expire_time<T>(mut self, v: T) -> Self
                where
                    T: std::convert::Into<wkt::Timestamp>,
                {
                    self.expire_time = std::option::Option::Some(v.into());
                    self
                }

                /// Sets or clears the value of [expire_time][crate::model::grant::timeline::event::Requested::expire_time].
                pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
                where
                    T: std::convert::Into<wkt::Timestamp>,
                {
                    self.expire_time = v.map(|x| x.into());
                    self
                }
            }

            impl wkt::message::Message for Requested {
                fn typename() -> &'static str {
                    "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.Timeline.Event.Requested"
                }
            }

            /// An event representing that the grant was approved.
            #[derive(Clone, Default, PartialEq)]
            #[non_exhaustive]
            pub struct Approved {
                /// Output only. The reason provided by the approver for approving the
                /// grant.
                pub reason: std::string::String,

                /// Output only. Username of the user who approved the grant.
                pub actor: std::string::String,

                pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
            }

            impl Approved {
                pub fn new() -> Self {
                    std::default::Default::default()
                }

                /// Sets the value of [reason][crate::model::grant::timeline::event::Approved::reason].
                pub fn set_reason<T: std::convert::Into<std::string::String>>(
                    mut self,
                    v: T,
                ) -> Self {
                    self.reason = v.into();
                    self
                }

                /// Sets the value of [actor][crate::model::grant::timeline::event::Approved::actor].
                pub fn set_actor<T: std::convert::Into<std::string::String>>(
                    mut self,
                    v: T,
                ) -> Self {
                    self.actor = v.into();
                    self
                }
            }

            impl wkt::message::Message for Approved {
                fn typename() -> &'static str {
                    "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.Timeline.Event.Approved"
                }
            }

            /// An event representing that the grant was denied.
            #[derive(Clone, Default, PartialEq)]
            #[non_exhaustive]
            pub struct Denied {
                /// Output only. The reason provided by the approver for denying the
                /// grant.
                pub reason: std::string::String,

                /// Output only. Username of the user who denied the grant.
                pub actor: std::string::String,

                pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
            }

            impl Denied {
                pub fn new() -> Self {
                    std::default::Default::default()
                }

                /// Sets the value of [reason][crate::model::grant::timeline::event::Denied::reason].
                pub fn set_reason<T: std::convert::Into<std::string::String>>(
                    mut self,
                    v: T,
                ) -> Self {
                    self.reason = v.into();
                    self
                }

                /// Sets the value of [actor][crate::model::grant::timeline::event::Denied::actor].
                pub fn set_actor<T: std::convert::Into<std::string::String>>(
                    mut self,
                    v: T,
                ) -> Self {
                    self.actor = v.into();
                    self
                }
            }

            impl wkt::message::Message for Denied {
                fn typename() -> &'static str {
                    "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.Timeline.Event.Denied"
                }
            }

            /// An event representing that the grant was revoked.
            #[derive(Clone, Default, PartialEq)]
            #[non_exhaustive]
            pub struct Revoked {
                /// Output only. The reason provided by the user for revoking the grant.
                pub reason: std::string::String,

                /// Output only. Username of the user who revoked the grant.
                pub actor: std::string::String,

                pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
            }

            impl Revoked {
                pub fn new() -> Self {
                    std::default::Default::default()
                }

                /// Sets the value of [reason][crate::model::grant::timeline::event::Revoked::reason].
                pub fn set_reason<T: std::convert::Into<std::string::String>>(
                    mut self,
                    v: T,
                ) -> Self {
                    self.reason = v.into();
                    self
                }

                /// Sets the value of [actor][crate::model::grant::timeline::event::Revoked::actor].
                pub fn set_actor<T: std::convert::Into<std::string::String>>(
                    mut self,
                    v: T,
                ) -> Self {
                    self.actor = v.into();
                    self
                }
            }

            impl wkt::message::Message for Revoked {
                fn typename() -> &'static str {
                    "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.Timeline.Event.Revoked"
                }
            }

            /// An event representing that the grant was withdrawn.
            #[derive(Clone, Default, PartialEq)]
            #[non_exhaustive]
            pub struct Withdrawn {
                pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
            }

            impl Withdrawn {
                pub fn new() -> Self {
                    std::default::Default::default()
                }
            }

            impl wkt::message::Message for Withdrawn {
                fn typename() -> &'static str {
                    "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.Timeline.Event.Withdrawn"
                }
            }

            /// An event representing that the grant has been scheduled to be
            /// activated later.
            #[derive(Clone, Default, PartialEq)]
            #[non_exhaustive]
            pub struct Scheduled {
                /// Output only. The time at which the access is granted.
                pub scheduled_activation_time: std::option::Option<wkt::Timestamp>,

                pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
            }

            impl Scheduled {
                pub fn new() -> Self {
                    std::default::Default::default()
                }

                /// Sets the value of [scheduled_activation_time][crate::model::grant::timeline::event::Scheduled::scheduled_activation_time].
                pub fn set_scheduled_activation_time<T>(mut self, v: T) -> Self
                where
                    T: std::convert::Into<wkt::Timestamp>,
                {
                    self.scheduled_activation_time = std::option::Option::Some(v.into());
                    self
                }

                /// Sets or clears the value of [scheduled_activation_time][crate::model::grant::timeline::event::Scheduled::scheduled_activation_time].
                pub fn set_or_clear_scheduled_activation_time<T>(
                    mut self,
                    v: std::option::Option<T>,
                ) -> Self
                where
                    T: std::convert::Into<wkt::Timestamp>,
                {
                    self.scheduled_activation_time = v.map(|x| x.into());
                    self
                }
            }

            impl wkt::message::Message for Scheduled {
                fn typename() -> &'static str {
                    "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.Timeline.Event.Scheduled"
                }
            }

            /// An event representing that the grant was successfully
            /// activated.
            #[derive(Clone, Default, PartialEq)]
            #[non_exhaustive]
            pub struct Activated {
                pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
            }

            impl Activated {
                pub fn new() -> Self {
                    std::default::Default::default()
                }
            }

            impl wkt::message::Message for Activated {
                fn typename() -> &'static str {
                    "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.Timeline.Event.Activated"
                }
            }

            /// An event representing that the grant activation failed.
            #[derive(Clone, Default, PartialEq)]
            #[non_exhaustive]
            pub struct ActivationFailed {
                /// Output only. The error that occurred while activating the grant.
                pub error: std::option::Option<rpc::model::Status>,

                pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
            }

            impl ActivationFailed {
                pub fn new() -> Self {
                    std::default::Default::default()
                }

                /// Sets the value of [error][crate::model::grant::timeline::event::ActivationFailed::error].
                pub fn set_error<T>(mut self, v: T) -> Self
                where
                    T: std::convert::Into<rpc::model::Status>,
                {
                    self.error = std::option::Option::Some(v.into());
                    self
                }

                /// Sets or clears the value of [error][crate::model::grant::timeline::event::ActivationFailed::error].
                pub fn set_or_clear_error<T>(mut self, v: std::option::Option<T>) -> Self
                where
                    T: std::convert::Into<rpc::model::Status>,
                {
                    self.error = v.map(|x| x.into());
                    self
                }
            }

            impl wkt::message::Message for ActivationFailed {
                fn typename() -> &'static str {
                    "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.Timeline.Event.ActivationFailed"
                }
            }

            /// An event representing that the grant was expired.
            #[derive(Clone, Default, PartialEq)]
            #[non_exhaustive]
            pub struct Expired {
                pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
            }

            impl Expired {
                pub fn new() -> Self {
                    std::default::Default::default()
                }
            }

            impl wkt::message::Message for Expired {
                fn typename() -> &'static str {
                    "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.Timeline.Event.Expired"
                }
            }

            /// An event representing that the grant has ended.
            #[derive(Clone, Default, PartialEq)]
            #[non_exhaustive]
            pub struct Ended {
                pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
            }

            impl Ended {
                pub fn new() -> Self {
                    std::default::Default::default()
                }
            }

            impl wkt::message::Message for Ended {
                fn typename() -> &'static str {
                    "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.Timeline.Event.Ended"
                }
            }

            /// An event representing that the policy bindings made by this grant were
            /// modified externally.
            #[derive(Clone, Default, PartialEq)]
            #[non_exhaustive]
            pub struct ExternallyModified {
                pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
            }

            impl ExternallyModified {
                pub fn new() -> Self {
                    std::default::Default::default()
                }
            }

            impl wkt::message::Message for ExternallyModified {
                fn typename() -> &'static str {
                    "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.Timeline.Event.ExternallyModified"
                }
            }

            #[derive(Clone, Debug, PartialEq)]
            #[non_exhaustive]
            pub enum Event {
                /// The grant was requested.
                Requested(std::boxed::Box<crate::model::grant::timeline::event::Requested>),
                /// The grant was approved.
                Approved(std::boxed::Box<crate::model::grant::timeline::event::Approved>),
                /// The grant was denied.
                Denied(std::boxed::Box<crate::model::grant::timeline::event::Denied>),
                /// The grant was revoked.
                Revoked(std::boxed::Box<crate::model::grant::timeline::event::Revoked>),
                /// The grant has been scheduled to give access.
                Scheduled(std::boxed::Box<crate::model::grant::timeline::event::Scheduled>),
                /// The grant was successfully activated to give access.
                Activated(std::boxed::Box<crate::model::grant::timeline::event::Activated>),
                /// There was a non-retriable error while trying to give access.
                ActivationFailed(
                    std::boxed::Box<crate::model::grant::timeline::event::ActivationFailed>,
                ),
                /// The approval workflow did not complete in the necessary duration,
                /// and so the grant is expired.
                Expired(std::boxed::Box<crate::model::grant::timeline::event::Expired>),
                /// Access given by the grant ended automatically as the approved
                /// duration was over.
                Ended(std::boxed::Box<crate::model::grant::timeline::event::Ended>),
                /// The policy bindings made by grant have been modified outside of PAM.
                ExternallyModified(
                    std::boxed::Box<crate::model::grant::timeline::event::ExternallyModified>,
                ),
                /// The grant was withdrawn.
                Withdrawn(std::boxed::Box<crate::model::grant::timeline::event::Withdrawn>),
            }
        }
    }

    /// Audit trail for the access provided by this grant.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct AuditTrail {
        /// Output only. The time at which access was given.
        pub access_grant_time: std::option::Option<wkt::Timestamp>,

        /// Output only. The time at which the system removed access. This could be
        /// because of an automatic expiry or because of a revocation.
        ///
        /// If unspecified, then access hasn't been removed yet.
        pub access_remove_time: std::option::Option<wkt::Timestamp>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl AuditTrail {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [access_grant_time][crate::model::grant::AuditTrail::access_grant_time].
        pub fn set_access_grant_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.access_grant_time = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [access_grant_time][crate::model::grant::AuditTrail::access_grant_time].
        pub fn set_or_clear_access_grant_time<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.access_grant_time = v.map(|x| x.into());
            self
        }

        /// Sets the value of [access_remove_time][crate::model::grant::AuditTrail::access_remove_time].
        pub fn set_access_remove_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.access_remove_time = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [access_remove_time][crate::model::grant::AuditTrail::access_remove_time].
        pub fn set_or_clear_access_remove_time<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.access_remove_time = v.map(|x| x.into());
            self
        }
    }

    impl wkt::message::Message for AuditTrail {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Grant.AuditTrail"
        }
    }

    /// Different states a grant can be in.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Unspecified state. This value is never returned by the server.
        Unspecified,
        /// The entitlement had an approval workflow configured and this grant is
        /// waiting for the workflow to complete.
        ApprovalAwaited,
        /// The approval workflow completed with a denied result. No access is
        /// granted for this grant. This is a terminal state.
        Denied,
        /// The approval workflow completed successfully with an approved result or
        /// none was configured. Access is provided at an appropriate time.
        Scheduled,
        /// Access is being given.
        Activating,
        /// Access was successfully given and is currently active.
        Active,
        /// The system could not give access due to a non-retriable error. This is a
        /// terminal state.
        ActivationFailed,
        /// Expired after waiting for the approval workflow to complete. This is a
        /// terminal state.
        Expired,
        /// Access is being revoked.
        Revoking,
        /// Access was revoked by a user. This is a terminal state.
        Revoked,
        /// System took back access as the requested duration was over. This is a
        /// terminal state.
        Ended,
        /// Access is being withdrawn.
        Withdrawing,
        /// Grant was withdrawn by the grant owner. This is a terminal state.
        Withdrawn,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::ApprovalAwaited => std::option::Option::Some(1),
                Self::Denied => std::option::Option::Some(3),
                Self::Scheduled => std::option::Option::Some(4),
                Self::Activating => std::option::Option::Some(5),
                Self::Active => std::option::Option::Some(6),
                Self::ActivationFailed => std::option::Option::Some(7),
                Self::Expired => std::option::Option::Some(8),
                Self::Revoking => std::option::Option::Some(9),
                Self::Revoked => std::option::Option::Some(10),
                Self::Ended => std::option::Option::Some(11),
                Self::Withdrawing => std::option::Option::Some(12),
                Self::Withdrawn => std::option::Option::Some(13),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::ApprovalAwaited => std::option::Option::Some("APPROVAL_AWAITED"),
                Self::Denied => std::option::Option::Some("DENIED"),
                Self::Scheduled => std::option::Option::Some("SCHEDULED"),
                Self::Activating => std::option::Option::Some("ACTIVATING"),
                Self::Active => std::option::Option::Some("ACTIVE"),
                Self::ActivationFailed => std::option::Option::Some("ACTIVATION_FAILED"),
                Self::Expired => std::option::Option::Some("EXPIRED"),
                Self::Revoking => std::option::Option::Some("REVOKING"),
                Self::Revoked => std::option::Option::Some("REVOKED"),
                Self::Ended => std::option::Option::Some("ENDED"),
                Self::Withdrawing => std::option::Option::Some("WITHDRAWING"),
                Self::Withdrawn => std::option::Option::Some("WITHDRAWN"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::ApprovalAwaited,
                3 => Self::Denied,
                4 => Self::Scheduled,
                5 => Self::Activating,
                6 => Self::Active,
                7 => Self::ActivationFailed,
                8 => Self::Expired,
                9 => Self::Revoking,
                10 => Self::Revoked,
                11 => Self::Ended,
                12 => Self::Withdrawing,
                13 => Self::Withdrawn,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "APPROVAL_AWAITED" => Self::ApprovalAwaited,
                "DENIED" => Self::Denied,
                "SCHEDULED" => Self::Scheduled,
                "ACTIVATING" => Self::Activating,
                "ACTIVE" => Self::Active,
                "ACTIVATION_FAILED" => Self::ActivationFailed,
                "EXPIRED" => Self::Expired,
                "REVOKING" => Self::Revoking,
                "REVOKED" => Self::Revoked,
                "ENDED" => Self::Ended,
                "WITHDRAWING" => Self::Withdrawing,
                "WITHDRAWN" => Self::Withdrawn,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::ApprovalAwaited => serializer.serialize_i32(1),
                Self::Denied => serializer.serialize_i32(3),
                Self::Scheduled => serializer.serialize_i32(4),
                Self::Activating => serializer.serialize_i32(5),
                Self::Active => serializer.serialize_i32(6),
                Self::ActivationFailed => serializer.serialize_i32(7),
                Self::Expired => serializer.serialize_i32(8),
                Self::Revoking => serializer.serialize_i32(9),
                Self::Revoked => serializer.serialize_i32(10),
                Self::Ended => serializer.serialize_i32(11),
                Self::Withdrawing => serializer.serialize_i32(12),
                Self::Withdrawn => serializer.serialize_i32(13),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.privilegedaccessmanager.v1.Grant.State",
            ))
        }
    }
}

/// Justification represents a justification for requesting access.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Justification {
    pub justification: std::option::Option<crate::model::justification::Justification>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Justification {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [justification][crate::model::Justification::justification].
    ///
    /// Note that all the setters affecting `justification` are mutually
    /// exclusive.
    pub fn set_justification<
        T: std::convert::Into<std::option::Option<crate::model::justification::Justification>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.justification = v.into();
        self
    }

    /// The value of [justification][crate::model::Justification::justification]
    /// if it holds a `UnstructuredJustification`, `None` if the field is not set or
    /// holds a different branch.
    pub fn unstructured_justification(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.justification.as_ref().and_then(|v| match v {
            crate::model::justification::Justification::UnstructuredJustification(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [justification][crate::model::Justification::justification]
    /// to hold a `UnstructuredJustification`.
    ///
    /// Note that all the setters affecting `justification` are
    /// mutually exclusive.
    pub fn set_unstructured_justification<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.justification = std::option::Option::Some(
            crate::model::justification::Justification::UnstructuredJustification(v.into()),
        );
        self
    }
}

impl wkt::message::Message for Justification {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.Justification"
    }
}

/// Defines additional types related to [Justification].
pub mod justification {
    #[allow(unused_imports)]
    use super::*;

    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Justification {
        /// A free form textual justification. The system only ensures that this
        /// is not empty. No other kind of validation is performed on the string.
        UnstructuredJustification(std::string::String),
    }
}

/// Message for requesting list of grants.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListGrantsRequest {
    /// Required. The parent resource which owns the grants.
    pub parent: std::string::String,

    /// Optional. Requested page size. The server may return fewer items than
    /// requested. If unspecified, the server picks an appropriate default.
    pub page_size: i32,

    /// Optional. A token identifying a page of results the server should return.
    pub page_token: std::string::String,

    /// Optional. Filtering results.
    pub filter: std::string::String,

    /// Optional. Hint for how to order the results
    pub order_by: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListGrantsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListGrantsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListGrantsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListGrantsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListGrantsRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [order_by][crate::model::ListGrantsRequest::order_by].
    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.order_by = v.into();
        self
    }
}

impl wkt::message::Message for ListGrantsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.ListGrantsRequest"
    }
}

/// Message for response to listing grants.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListGrantsResponse {
    /// The list of grants.
    pub grants: std::vec::Vec<crate::model::Grant>,

    /// A token identifying a page of results the server should return.
    pub next_page_token: std::string::String,

    /// Locations that could not be reached.
    pub unreachable: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListGrantsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [grants][crate::model::ListGrantsResponse::grants].
    pub fn set_grants<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Grant>,
    {
        use std::iter::Iterator;
        self.grants = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListGrantsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable][crate::model::ListGrantsResponse::unreachable].
    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListGrantsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.ListGrantsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListGrantsResponse {
    type PageItem = crate::model::Grant;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.grants
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Request message for `SearchGrants` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SearchGrantsRequest {
    /// Required. The parent which owns the grant resources.
    pub parent: std::string::String,

    /// Required. Only grants which the caller is related to by this relationship
    /// are returned in the response.
    pub caller_relationship: crate::model::search_grants_request::CallerRelationshipType,

    /// Optional. Only grants matching this filter are returned in the response.
    pub filter: std::string::String,

    /// Optional. Requested page size. The server may return fewer items than
    /// requested. If unspecified, server picks an appropriate default.
    pub page_size: i32,

    /// Optional. A token identifying a page of results the server should return.
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SearchGrantsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::SearchGrantsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [caller_relationship][crate::model::SearchGrantsRequest::caller_relationship].
    pub fn set_caller_relationship<
        T: std::convert::Into<crate::model::search_grants_request::CallerRelationshipType>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.caller_relationship = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::SearchGrantsRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::SearchGrantsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::SearchGrantsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for SearchGrantsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.SearchGrantsRequest"
    }
}

/// Defines additional types related to [SearchGrantsRequest].
pub mod search_grants_request {
    #[allow(unused_imports)]
    use super::*;

    /// Different types of relationships a user can have with a grant.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum CallerRelationshipType {
        /// Unspecified caller relationship type.
        Unspecified,
        /// The user created this grant by calling `CreateGrant` earlier.
        HadCreated,
        /// The user is an approver for the entitlement that this grant is parented
        /// under and can currently approve/deny it.
        CanApprove,
        /// The caller had successfully approved/denied this grant earlier.
        HadApproved,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [CallerRelationshipType::value] or
        /// [CallerRelationshipType::name].
        UnknownValue(caller_relationship_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod caller_relationship_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl CallerRelationshipType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::HadCreated => std::option::Option::Some(1),
                Self::CanApprove => std::option::Option::Some(2),
                Self::HadApproved => std::option::Option::Some(3),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => {
                    std::option::Option::Some("CALLER_RELATIONSHIP_TYPE_UNSPECIFIED")
                }
                Self::HadCreated => std::option::Option::Some("HAD_CREATED"),
                Self::CanApprove => std::option::Option::Some("CAN_APPROVE"),
                Self::HadApproved => std::option::Option::Some("HAD_APPROVED"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for CallerRelationshipType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for CallerRelationshipType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for CallerRelationshipType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::HadCreated,
                2 => Self::CanApprove,
                3 => Self::HadApproved,
                _ => Self::UnknownValue(caller_relationship_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for CallerRelationshipType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "CALLER_RELATIONSHIP_TYPE_UNSPECIFIED" => Self::Unspecified,
                "HAD_CREATED" => Self::HadCreated,
                "CAN_APPROVE" => Self::CanApprove,
                "HAD_APPROVED" => Self::HadApproved,
                _ => Self::UnknownValue(caller_relationship_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for CallerRelationshipType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::HadCreated => serializer.serialize_i32(1),
                Self::CanApprove => serializer.serialize_i32(2),
                Self::HadApproved => serializer.serialize_i32(3),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for CallerRelationshipType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<CallerRelationshipType>::new(
                ".google.cloud.privilegedaccessmanager.v1.SearchGrantsRequest.CallerRelationshipType"))
        }
    }
}

/// Response message for `SearchGrants` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SearchGrantsResponse {
    /// The list of grants.
    pub grants: std::vec::Vec<crate::model::Grant>,

    /// A token identifying a page of results the server should return.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SearchGrantsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [grants][crate::model::SearchGrantsResponse::grants].
    pub fn set_grants<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Grant>,
    {
        use std::iter::Iterator;
        self.grants = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::SearchGrantsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for SearchGrantsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.SearchGrantsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for SearchGrantsResponse {
    type PageItem = crate::model::Grant;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.grants
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Message for getting a grant.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetGrantRequest {
    /// Required. Name of the resource.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetGrantRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetGrantRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetGrantRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.GetGrantRequest"
    }
}

/// Request message for `ApproveGrant` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ApproveGrantRequest {
    /// Required. Name of the grant resource which is being approved.
    pub name: std::string::String,

    /// Optional. The reason for approving this grant. This is required if the
    /// `require_approver_justification` field of the `ManualApprovals` workflow
    /// used in this grant is true.
    pub reason: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ApproveGrantRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::ApproveGrantRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [reason][crate::model::ApproveGrantRequest::reason].
    pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.reason = v.into();
        self
    }
}

impl wkt::message::Message for ApproveGrantRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.ApproveGrantRequest"
    }
}

/// Request message for `DenyGrant` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DenyGrantRequest {
    /// Required. Name of the grant resource which is being denied.
    pub name: std::string::String,

    /// Optional. The reason for denying this grant. This is required if
    /// `require_approver_justification` field of the `ManualApprovals` workflow
    /// used in this grant is true.
    pub reason: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DenyGrantRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DenyGrantRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [reason][crate::model::DenyGrantRequest::reason].
    pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.reason = v.into();
        self
    }
}

impl wkt::message::Message for DenyGrantRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.DenyGrantRequest"
    }
}

/// Request message for `RevokeGrant` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct RevokeGrantRequest {
    /// Required. Name of the grant resource which is being revoked.
    pub name: std::string::String,

    /// Optional. The reason for revoking this grant.
    pub reason: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl RevokeGrantRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::RevokeGrantRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [reason][crate::model::RevokeGrantRequest::reason].
    pub fn set_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.reason = v.into();
        self
    }
}

impl wkt::message::Message for RevokeGrantRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.RevokeGrantRequest"
    }
}

/// Message for creating a grant
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateGrantRequest {
    /// Required. Name of the parent entitlement for which this grant is being
    /// requested.
    pub parent: std::string::String,

    /// Required. The resource being created.
    pub grant: std::option::Option<crate::model::Grant>,

    /// Optional. An optional request ID to identify requests. Specify a unique
    /// request ID so that if you must retry your request, the server knows to
    /// ignore the request if it has already been completed. The server guarantees
    /// this for at least 60 minutes after the first request.
    ///
    /// For example, consider a situation where you make an initial request and the
    /// request times out. If you make the request again with the same request
    /// ID, the server can check if original operation with the same request ID
    /// was received, and if so, ignores the second request. This prevents
    /// clients from accidentally creating duplicate grants.
    ///
    /// The request ID must be a valid UUID with the exception that zero UUID is
    /// not supported (00000000-0000-0000-0000-000000000000).
    pub request_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateGrantRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateGrantRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [grant][crate::model::CreateGrantRequest::grant].
    pub fn set_grant<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Grant>,
    {
        self.grant = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [grant][crate::model::CreateGrantRequest::grant].
    pub fn set_or_clear_grant<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Grant>,
    {
        self.grant = v.map(|x| x.into());
        self
    }

    /// Sets the value of [request_id][crate::model::CreateGrantRequest::request_id].
    pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_id = v.into();
        self
    }
}

impl wkt::message::Message for CreateGrantRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.CreateGrantRequest"
    }
}

/// Represents the metadata of the long-running operation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OperationMetadata {
    /// Output only. The time the operation was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The time the operation finished running.
    pub end_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Server-defined resource path for the target of the operation.
    pub target: std::string::String,

    /// Output only. Name of the verb executed by the operation.
    pub verb: std::string::String,

    /// Output only. Human-readable status of the operation, if any.
    pub status_message: std::string::String,

    /// Output only. Identifies whether the user has requested cancellation
    /// of the operation. Operations that have been cancelled successfully
    /// have [Operation.error][] value with a
    /// [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to
    /// `Code.CANCELLED`.
    ///
    /// [google.rpc.Status.code]: rpc::model::Status::code
    pub requested_cancellation: bool,

    /// Output only. API version used to start the operation.
    pub api_version: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OperationMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model::OperationMetadata::end_time].
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model::OperationMetadata::end_time].
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [target][crate::model::OperationMetadata::target].
    pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.target = v.into();
        self
    }

    /// Sets the value of [verb][crate::model::OperationMetadata::verb].
    pub fn set_verb<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.verb = v.into();
        self
    }

    /// Sets the value of [status_message][crate::model::OperationMetadata::status_message].
    pub fn set_status_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.status_message = v.into();
        self
    }

    /// Sets the value of [requested_cancellation][crate::model::OperationMetadata::requested_cancellation].
    pub fn set_requested_cancellation<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.requested_cancellation = v.into();
        self
    }

    /// Sets the value of [api_version][crate::model::OperationMetadata::api_version].
    pub fn set_api_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.api_version = v.into();
        self
    }
}

impl wkt::message::Message for OperationMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.privilegedaccessmanager.v1.OperationMetadata"
    }
}
